1 新版本镜像制作教程(非注入方式)
Windows 镜像制作
-
正常安装 Windows Server 版本。
-
登录系统,下载并默认安装 Cloudbase-Init 和 QEMU Guest Agent:
- 下载下列配置文件,放置到镜像的
C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf目录:
-
关闭防火墙
-
关机,制作完成,得到的 qcow2 就是云镜像;
Linux 镜像制作
使用官方标准 ISO 安装(Linux 系统有很多,命令各不相同 但一定要安装的组件 sfdisk growpart cloud-init qemu-guest-agent)
根据需要关闭软件(不同系统不同命令): (CentOS 请一定关闭 SElinux),NetworkManager,iptables,firewalld
安装必须的工具(不同系统不同命令): cloud-init, qemu-guest-agent
根据需要安装软件,比如以下软件(不同系统不同命令): vim, curl, wget, net-tools
- 系统安装要求:
最小化、上海时区、语言英文、关闭 kdump、不锁定 root、不禁止 root 密码登录
- 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
sed -i '/^SELINUX=/ s/enforcing/disabled/g' /etc/selinux/config- 设置时区
timedatectl set-timezone Asia/Shanghai- 安装云相关组件及附件组件
dnf install util-linux cloud-utils-growpart -y
dnf install qemu-guest-agent cloud-init -y
dnf install vim curl wget net-tools chrony -y- 配置/etc/ssh/sshd_config 中的选项
找到选项: PermitRootLogin yes 如果选项前有#号就去掉#号再修改值为 yes
找到选项: PasswordAuthentication yes 如果选项前有#号就去掉#号再修改值为 yes
# 若是ubuntu 需要把 执行 rm /etc/ssh/sshd_config.d/* -rf- 编辑 cloud-init 配置文件 /etc/cloud/cloud.conf
将选项 disable_root: 0 # 原始值为1, 改为0. 打开root登录
将选项 ssh_pwauth: 1 #原始值为0, 改为1. 开启密码登录
system_info:
default_user:
name: centos << 此处改为 root
lock_passwd: true << 此处改为 false
gecos: Cloud User
groups: [adm, systemd-journal]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
distro: rhel
paths:
cloud_dir: /var/lib/cloud
templates_dir: /etc/cloud/templates
ssh_svcname: sshd- 清理镜像
CentOS 清除多余网卡配置 /etc/sysconfig/network-scripts/ifcfg-[eth|eno 等网卡对应名称的文件](一定要保留 ifcfg-lo)。
清理 root 目录:
rm ~/*清理 history:
rm ~/.bash_history && history -c- 关机后压缩镜像,得到的 qcow2 就是制作好的镜像
shutdown -h now
qemu-img convert -p -c -O qcow2 vm-205-disk-0.qcow2 CentOS-9_x64.qcow2